<!--
    Exception 预警信息
    @Author: linxp
    @Date: 2020-12-22
-->
<template>
  <div class="xsyq">
    <h3 class="xsyq__title"><i class="xsyq__icon"></i>预警总数</h3>
    <div class="xsyq__main">
      <div class="xsyq__item">
        <div class="info-overview" v-if="clues.length">
          <li
            class="info-overview__item"
            v-for="(item, index) in clues"
            :class="[
              !index ? 'oneweek' : index == 1 ? 'today' : index == 2 ? 'tomorrow' : 'sevenDays',
              timeCurrentIndex === index ? 'is-active' : ''
            ]"
            :key="item.name"
            @click="handleTimeFilter(index, tabActive)"
          >
            <div class="clue__node--title">{{ item.name }}</div>
            <div style="display: flex">
              <div class="clue__numbox">
                <p>已办结</p>
                <p class="clue__data">{{ item.ybs }}</p>
              </div>
              <div class="clue__numbox">
                <p>未办结</p>
                <p class="clue__data">{{ item.dbs }}</p>
              </div>
              <!-- <div class="clue__numbox">
                <p>交接</p>
                <p class="clue__data">{{ item.process.total }}</p>
              </div>
              <div class="clue__numbox">
                <p>在办</p>
                <p class="clue__data">{{ item.process.total }}</p>
              </div> -->
            </div>
          </li>
        </div>
      </div>
      <div class="xsyq__item">
        <div class="info-list">
          <el-tabs v-model="tabActive" @tab-click="handleTabClick">
            <el-tab-pane label="已办结" name="1"></el-tab-pane>
            <el-tab-pane label="未办结" name="0"></el-tab-pane>
            <!-- <el-tab-pane label="交接" name="handover"></el-tab-pane>
            <el-tab-pane label="在办" name="process"></el-tab-pane> -->
          </el-tabs>
          <ul class="info-list__main" v-if="clueList.length">
            <li
              v-for="item in clueList"
              class="info-list__item"
              :key="item.ID"
              @click="handleDetail(item)"
              :class="[currentActiveId === item.ID ? 'is-active' : '']"
            >
              <span class="clue"></span>
              <p class="b-ellipsis" :title="item.TITLE">{{ item.TITLE }}</p>
            </li>
          </ul>
          <no-record v-else></no-record>
        </div>
      </div>

      <div class="xsyq__item">
        <div class="info-detail">
          <div class="info-detail__header">
            <h3>{{ detail.createOrgName }}</h3>
            <span>{{ detail.sendTime }}</span>
          </div>
          <div class="info-detail__cont">
            <div class="content" v-if="Object.keys(detail).length">
              <dg-scrollbar>
                <p>
                  {{ detail.zw }}
                </p>
              </dg-scrollbar>
              <dg-button class="btn-detail" type="text" @click="routeToClueDetail(detail)">详情 ></dg-button>
            </div>
            <no-record v-else></no-record>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getFlowDetail, yjxxSum, yjxxSumTypeList } from '@/api/common';
import { routeToClueDetail } from '@/utils/data-utils';
import InfiniteScroll from '@/components/infinite-scroll';

export default {
  name: 'yjxx',
  components: {
    InfiniteScroll
  },
  data() {
    return {
      currentActiveId: '',
      clues: [],
      tabActive: '1',
      timeCurrentIndex: 0, // 当前选中数据
      detail: {},
      clueList: [],
      routeToClueDetail
    };
  },
  methods: {
    getFlowDetail() {
      getFlowDetail(this.currentActiveId).then(({ data }) => {
        this.detail = data;
      });
    },
    handleTabClick(tab) {
      this.handleTimeFilter(this.timeCurrentIndex, tab.name);
    },
    /**
     * 根据分类获取数据
     * @param {object} item 当前点击项数据
     */
    handleTimeFilter(index = 0, tabType = '1') {
      const code = this.clues[index].code;
      this.timeCurrentIndex = index;
      this.tabActive = tabType;

      yjxxSumTypeList({
        yjxxType: code,
        type: tabType
      }).then(res => {
        this.clueList = res.data;
        if (Array.isArray(this.clueList) && this.clueList.length) {
          this.currentActiveId = this.clueList[0].ID;
          this.getFlowDetail();
        } else {
          this.detail = {};
        }
      });
    },
    /**
     * 点击查看详情
     * @param {object} 当前点击数据
     */
    handleDetail(item) {
      this.currentActiveId = item.ID;
      this.getFlowDetail();
    }
  },
  created() {
    yjxxSum().then(({ data }) => {
      this.clues = data;
      if (Array.isArray(this.clues) && this.clues.length) {
        this.handleTimeFilter();
      }
    });
  }
};
</script>

<style lang="scss" scoped>
@mixin borderR {
  content: '';
  width: 3px;
  height: 5.625rem;
  position: absolute;
  top: 0;
  left: -3px;
  border-radius: 2px 0 0 2px;
  box-shadow: 0px 2px 8px 0px rgba(64, 144, 255, 0.45);
}

.xsyq {
  display: flex;
  flex-direction: column;
  padding: 0 1.5rem 3rem;
  background: #fff;
  &__title {
    flex: none;
    position: relative;
    padding-left: 3rem;
    margin-bottom: 0.5rem;
  }
  &__icon {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    background: url('../../../assets/images/icon-yj.png') no-repeat center;
    background-size: contain;
    position: absolute;
    left: 0;
    top: 3px;
  }
  &__main {
    flex: 1;
    display: flex;
    justify-content: space-between;
    height: 100%;
    width: 100%;
  }
  &__item {
    flex: none;
    display: flex;
    position: relative;
    width: 27%;
    max-width: 25rem;

    .info-overview {
      margin-left: 3rem;
      position: relative;
      z-index: 0;
      &:after {
        content: '';
        position: absolute;
        top: 0;
        left: -2rem;
        height: calc(100% - 2.825rem - 8.4px);
        width: 1px;
        background: #4090ff;
      }
      &__item.is-active:after {
        content: '';
        position: absolute;
        top: 3.5rem;
        left: 90%;
        height: 1px;
        width: 100%;
        background: #4090ff;
        z-index: -1;
      }
    }
  }
}

.info-overview {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;

  &__item {
    flex: none;

    position: relative;
    padding: 1rem 2rem;
    background-blend-mode: normal, normal;
    border-radius: 4px;
    font-size: 14px;
    color: rgba($color: #ffffff, $alpha: 0.65);
    line-height: 1.2;
    cursor: pointer;
    box-sizing: border-box;
    &.oneweek {
      background: url(../../../../static/themes/images/page/bg-blue.png) no-repeat;
      background-size: cover;
    }
    &.today {
      background: url(../../../../static/themes/images/page/bg-dblue.png) no-repeat;
      background-size: cover;
    }
    &.tomorrow {
      background: url(../../../../static/themes/images/page/bg-green.png) no-repeat;
      background-size: cover;
    }
    &.sevenDays {
      background: url(../../../../static/themes/images/page/bg-yello.png) no-repeat;
      background-size: cover;
    }
    &::before {
      content: '';
      position: absolute;
      top: 50%;
      left: -2rem;
      height: 1px;
      width: 2rem;
      background: #4090ff;
    }

    &--title {
      font-size: 1rem;
      color: #fff;
    }
  }

  &__item + &__item {
    margin-top: 0.5rem;
  }
}

@mixin info-box {
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;

  background-color: #ffffff;
  box-shadow: 0px 2px 8px 0px rgba(64, 144, 255, 0.45);
  border-radius: 2px;
}
.info-list {
  @include info-box;
  position: relative;
  z-index: 0;
  &:after {
    content: '';
    position: absolute;
    top: 3.5rem;
    right: -100%;
    height: 1px;
    width: 100%;
    background: #4090ff;
    z-index: -1;
  }
  .el-tabs {
    flex: none;
  }
  &__main {
    // flex: 1;
    height: 370px;
    padding: 0 1rem 0;
    overflow-y: scroll;
  }
  &__cont {
    position: relative;
    height: 100%;
    .content {
      height: 100%;
    }
    .btn-detail {
      position: absolute;
      right: 1rem;
    }
  }
  &__item {
    display: flex;
    align-items: flex-start;
    list-style: none;
    font-size: 0.875rem;
    color: rgba($color: #000000, $alpha: 0.85);
    text-align: justify;
    margin-bottom: 22px;
    height: 1rem;
    span {
      width: 0.5rem;
      height: 0.5rem;
      border-radius: 2px;
      margin-right: 0.375rem;
      margin-top: 0.3rem;
      background-color: #999;
    }
    p {
      flex: 1;
      line-height: 1.2;
      cursor: pointer;
      text-align: justify;
    }
    &:hover,
    &.is-active {
      color: #4090ff;
      span {
        background-color: #4090ff;
      }
    }
  }

  /deep/.el-tabs__nav {
    margin-left: 1rem;
  }
  /deep/.el-tabs__item {
    height: 3.5rem;
    line-height: 3.5rem;
    font-size: 1rem;
    color: rgba($color: #000000, $alpha: 0.65);
    &.is-active {
      color: #4090ff;
    }
  }
  /deep/.el-tabs__nav-wrap::after {
    height: 1px;
    background-color: rgba($color: #000000, $alpha: 0.09);
  }
}

.info-detail {
  @include info-box;

  &__header {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 3.5rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba($color: #000000, $alpha: 0.09);
    h3 {
      font-size: 1rem;
      color: rgba($color: #000000, $alpha: 0.85);
    }
    span {
      font-size: 0.875rem;
      color: rgba($color: #000000, $alpha: 0.65);
    }
  }
  &__cont {
    flex: 1;
    padding: calc(15px - 0.4rem) 0 1rem 0;
    position: relative;
    height: 100%;
    .content {
      height: 356px;
    }
    .btn-detail {
      position: absolute;
      right: 1rem;
      bottom: 0;
    }
    p {
      padding: 0 1rem;
      word-break: break-all;
    }
  }
}
.clue {
  &__detail {
    display: flex;
    flex-direction: column;
    height: 26rem;
    h3 {
      font-size: 1rem;
      color: rgba($color: #000000, $alpha: 0.85);
    }
  }

  &__list-detail {
    height: 100%;
    background-color: #ffffff;
    box-shadow: 0px 2px 8px 0px rgba(64, 144, 255, 0.45);
    border-radius: 2px;
    p {
      padding: 7px 1.5rem 1.5rem;
      text-align: justify;
    }
  }
  &__numbox {
    display: flex;
    flex: 1;
    flex-direction: column;
    margin-top: 0.5rem;
  }
  &__data {
    font-size: 0.875rem;
    color: #fff;
  }
  &__choose {
    position: relative;
    &::after {
      content: '';
      position: absolute;
      top: 50%;
      right: -3rem;
      transform: translateY(-50%);
      width: 3rem;
      height: 1px;
      background-color: #4090ff;
    }
  }
  &__cont {
    height: 22rem;
    ul {
      padding: 0 1rem 1rem 1rem;
      li {
      }
    }
  }
  .is-hasline {
    position: relative;
    &::before {
      content: '';
      position: absolute;
      top: 3.5rem;
      left: -2rem;
      height: 1px;
      width: 2rem;
      background: #4090ff;
    }
  }
  &__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 3.5rem;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba($color: #000000, $alpha: 0.09);
    h3 {
      font-size: 1rem;
      color: rgba($color: #000000, $alpha: 0.85);
    }
    span {
      font-size: 0.875rem;
      color: rgba($color: #000000, $alpha: 0.65);
    }
  }
}
</style>
